package com.chen.internalcommon.util;

import com.chen.internalcommon.constant.TokenConstants;

/**
 * @author chenLiuPing
 **/
public class RedisPrefixUtils {


    private static final   String VERIFICATION_CODE_PREFIX = "verification-code-";
    private static final String TOKEN_PREFIX = "token-";

    public static String blackDeviceCodePrefix = "black-device-";

    public static String generateCodeKeyByPhone(String phone, String identity) {
        return VERIFICATION_CODE_PREFIX + identity + "-" +  phone;
    }

    private static String generateTokenKey(String phone, String identity, String tokenType) {
        return TOKEN_PREFIX + phone + "-" + identity + "-" + tokenType;
    }

    public static String generateAccessTokenKey(String phone, String identity) {
        return generateTokenKey(phone, identity, TokenConstants.ACCESS_TOKEN_TYPE);
    }

    public static String generateRefreshTokenKey(String phone, String identity) {
        return generateTokenKey(phone, identity, TokenConstants.REFRESH_TOKEN_TYPE);
    }

    public static String generateDeviceCodeKey(String deviceCode) {
        return blackDeviceCodePrefix + deviceCode;
    }


}
